﻿/*****Game channel created at 2008-08-31 by onemax*********************************************************/
Pui.combo={        
		afterCreate:function(){
			var doc=document;
			var docElement=doc.documentElement;
			var sHeight=docElement.clientHeight;
			var dH=docElement.scrollHeight>sHeight?docElement.scrollHeight:sHeight;
			var scH=docElement.scrollTop>=0?(docElement.scrollTop+sHeight/2):sHeight;
			var h=scH-$(".up_1").height()/2;
			var w=docElement.clientWidth/2-$(".up_1").width()/2;
			$(".uper").height(dH).show();
			$(".up_1").css({top:h,left:w}).show();
			return false;

		},
		closeDiv:function(){
			$(".uper").hide();
			$(".up_1").hide();
		},
		checkIds:function(path){
			var arr=$(""+path+" input:checked");
			var ids='';
			if(arr.length==0)
			{
				alert("您还没有选择");
				return
			}		
			for(var i=0;i<arr.length;i++){
				if(i==0) ids=arr.eq(i).attr("id")
				else ids+=','+arr.eq(i).attr("id");
			}
			return ids;
		},
		Addpage:function(addtype,ComboID){
			document.getElementById("AddSrc").src='addcontent.aspx?id=0&type='+addtype+'&curpage=1&cid='+ComboID;
			Pui.combo.afterCreate();
		},
		addDom:function(){
			if(!$("#sendMsg").length)
			{
				$('#Prompt h3').after('<p id="sendMsg" class="p1"></p>');
				$('#btnlog').after('<input id="Back" class="back" type="button" value="确 定" />&nbsp;&nbsp;<input id="ibtn_f2" class="back" type="button" value="关 闭" />');
				$("#ibtn_f2").bind("click",Pui.combo.closeMsgDiv);
			}

		},
		showtips:function(types,otitle,ocontent,func){
			Pui.newSH.showLogDiv();	
			Pui.combo.addDom();
			otitle=otitle||'';
			ocontent=ocontent||''
			//types:1成功;2等待\审核;3失败;(两个按钮)4提醒/询问;5失败(一个按钮)
			switch(types){
			case 1:									
				$("#Prompt .k")[0].className="k suc";
				$("#Back").val("关 闭");
				$("#ibtn_f2").hide();
				break;
			case 2:										
				$("#Prompt .k")[0].className="k waiting";
				$("#Back").val("关 闭");
				$("#ibtn_f2").hide();
				break;
			case 3:										
				$("#Prompt .k")[0].className="k err";
				$("#Back").val("重新试试");
				$("#ibtn_f2").val("关 闭").show();
				break;
			case 4:										
				$("#Prompt .k")[0].className="k ask";
				$("#Back").val("确 定");
				$("#ibtn_f2").val("取 消").show();;
				break;
			case 5:										
				$("#Prompt .k")[0].className="k err";
				$("#Back").val("关 闭");	
				$("#ibtn_f2").hide();
			}
			if(func)
				$("#Back").bind("click",function(){Pui.combo.closeMsgDiv();eval(func);});
			else $("#Back").bind("click",Pui.combo.closeMsgDiv);
			$("#Prompt h3").html(otitle);
			$("#sendMsg").html(ocontent);
			$("#Prompt").show();				
		},
		closeMsgDiv:function(){
			$("#Back").unbind();
			$("#Prompt").hide();
			$("#zhezhao").hide();	
		}									
};
//add for friend
function f_addfriend(userid)
{
	if(_is_login)
	{
		Pui.loadScript(baseurl+"/space/personjs.aspx?dotype=1&userid="+userid+"");
		if(typeof(_userid)!='undefined') _userid=null;
	}else{		
		flag=3;
		_userid=userid;
		Pui.newSH.loginfo();

	}	
}
//add by xiangmz
function f_comboInterFace(otype,atype,comboid,objid)
{
	if ( otype=="exit" )
	{
		var functionstring = "f_deleteOK('"+otype+"','"+atype+"',"+comboid+","+_user.uid+")";
		Pui.combo.showtips(4,'确认退出社团？','您确定要退出此社团吗？退出后，您将无法再将您的作品分享到这个社团中！',functionstring);
	}
	else if ( otype=="add"&&!_is_login )
	{
			flag=4;
			addPram={otype:otype,atype:atype,comboid:comboid};
			Pui.newSH.loginfo();
	}else{
			Pui.loadScript("combointerface.aspx?otype="+otype+"&atype="+atype+"&comboid="+comboid+"&objid="+objid);	
	}
}
function f_deleteOK(otype,atype,comboid,objid)
{
	Pui.loadScript("combointerface.aspx?otype="+otype+"&atype="+atype+"&comboid="+comboid+"&objid="+objid);
}
function comboCallBack()
{
	window.location.reload();
}
function f_comboCallBack(cachetype)
{
	var cachetype="&ctype="+cachetype;
	var href = window.location.toString();
	if(href.indexOf("&ctype")>0)
	 {
		href = href.substring(0,href.indexOf("&ctype"));
	 }
	window.location.href=href+cachetype;
}
//add by xiangmz
String.prototype.codeLength=function(){
	 var len=0;
	 if(this==null||this.length==0)
	  return 0;
	 var str=this.replace(/(^\s*)|(\s*$)/g,"");//去掉空格
	 for(i=0;i<str.length;i++)
	  if(str.charCodeAt(i)>0&&str.charCodeAt(i)<128)
	   len++;
	  else 
	   len+=2;
	 return len;
} 
  
  
$.fn.check = function(mode){
   var mode = mode || 'on'; //default
    return this.each(function(){
        switch(mode){
            case 'on':
                this.checked = true;
                break;
            case 'off':
                this.checked = false;
                break;
            case 'toggle':
            	if(this.disabled==false)
                this.checked = !this.checked;
                break;
        }
    });
};

$(function(){
	if($("#checkall").length){
		$("#checkall").click(function(){
			$(".addList input:checkbox").check('on');
		});
	}
		if($("#checkoff").length){
		$("#checkoff").click(function(){
			$(".addList input:checkbox").check('toggle')
		});
	}

});
